﻿unit uCxtPackage;

interface

uses
  SysUtils, Classes, DB, uDZSysUtils, uDZSerializer, uDZPersistent,
  uGxtSvcIntf, uCxtConst, uCxtTypes;

type
  TRequestPackage = class(TDzPersistent)
  private
    fReqType: TRequestType;
    //fUserID: Integer;
    fSessionID: AnsiString;
    //fUserName: string;
    fSerialNo: Integer;
  public
    ForwardLink: TRequestPackage;
    property ReqType: TRequestType read fReqType;
  published
    //property UserID: Integer read fUserID write fUserID;
    //property UserName: string read fUserName write fUserName;
    property SessionID: AnsiString read fSessionID write fSessionID;

    // add by zhouzuoji, 2011-10-10 16:44
    // for concurrent requests support
    property SerialNo: Integer read fSerialNo write fSerialNo;
  end;
  
  TRequestClass = class of TRequestPackage;
  
  TResponsePackage = class(TDzPersistent)
  private
    fStatusCode: Integer;
    fStatusText: WideString;
    fServerTime: TDateTime;
    fSerialNo: Integer;
  public
    constructor Create; override;
    function GetSuccess: Boolean;
    property Success: Boolean read GetSuccess;
  published
    property StatusCode: Integer read fStatusCode write fStatusCode;
    property StatusText: WideString read fStatusText write fStatusText;
    property ServerTime: TDateTime read fServerTime write fServerTime;

    // add by zhouzuoji, 2011-10-10 16:44
    // for concurrent requests support
    property SerialNo: Integer read fSerialNo write fSerialNo;
  end;
  
  TResponseClass = class of TResponsePackage;

  TREQRemoveObjs = class(TRequestPackage)
  private
    fObjs: TDzPersistentList;
    procedure SetObjs(const Value: TDzPersistentList);
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Objs: TDzPersistentList read fObjs write SetObjs;
  end;
  
  TRESRemoveObjs = class(TResponsePackage)
  private
    fRemoved: Integer;
  published
    property Removed: Integer read fRemoved write fRemoved; 
  end;

  TRESAddObject = class(TResponsePackage)
  private
    fGUID: Integer;
  published
    property GUID: Integer read fGUID write fGUID;
  end;
  
  TREQLogin = class(TRequestPackage)
  private
    fPassword: AnsiString;
    fMinorVersion: Integer;
    fMajorVersion: Integer;
    fBuildNumber: Integer;
    fReleaseNumber: Integer;
    fComputerID: AnsiString;
    fOemName: WideString;
    fUserName: WideString;
  public
    constructor Create; override;
  published
    property UserName: WideString read fUserName write fUserName;
    property Password: AnsiString read fPassword write fPassword;
    property ComputerID: AnsiString read fComputerID write fComputerID;
    property OemName: WideString read fOemName write fOemName;
    property MajorVersion: Integer read fMajorVersion write fMajorVersion;
    property MinorVersion: Integer read fMinorVersion write fMinorVersion;
    property ReleaseNumber: Integer read fReleaseNumber write fReleaseNumber;
    property BuildNumber: Integer read fBuildNumber write fBuildNumber;
  end;

  TRESLogin = class(TResponsePackage)
  private
    fUserInfo: TUserInfo;
    fServerSetting: TServerSetting;
    fSessionID: AnsiString;
    fWelcomeMessage: WideString;
    fInternetIP: AnsiString;
    fInternetPort: Word;
    fAgentTel: AnsiString;
    procedure SetUserInfo(const Value: TUserInfo);
  protected
    procedure ReadProperties(const Reader: IDzClassReader;
      Options: TDzArchiveOptions); override;
    procedure WriteProperties(const Writer: IDzClassWriter;
      Options: TDzArchiveOptions); override;
  public
    constructor Create; override;
    destructor Destroy; override;
    property UserInfo: TUserInfo read fUserInfo write SetUserInfo;
  published
    property SessionID: AnsiString read fSessionID write fSessionID;
    property InternetIP: AnsiString read fInternetIP write fInternetIP;
    property InternetPort: Word read fInternetPort write fInternetPort;
    property WelcomeMessage: WideString read fWelcomeMessage write fWelcomeMessage;
    property ServerSetting: TServerSetting read fServerSetting write fServerSetting;
    property AgentTel: AnsiString read fAgentTel write fAgentTel;
  end;

  TREQLogout = class(TRequestPackage)
  public
    constructor Create; override;
  end;

  TREQAccountOperation = class(TRequestPackage)
  private
    fUserInfo: TUserInfo;
    procedure SetUserInfo(const Value: TUserInfo);
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property UserInfo: TUserInfo read FUserInfo write SetUserInfo;
  end;

  TREQAddAccount = class(TREQAccountOperation)
  private
    fFlag: Boolean;
  public
    constructor Create; override;
  published
    property Flag: Boolean read fFlag write fFlag;
  end;

  TRESAddAccount = class(TResponsePackage)
  private
    fFlag: Boolean;
    fAgentTel: AnsiString;
    fAgentName: WideString;
  published
    property Flag: Boolean read fFlag write fFlag;
    property AgentTel: AnsiString read fAgentTel write fAgentTel;
    property AgentName: WideString read fAgentName write fAgentName;
  end;

  TREQModifyAccount = class(TREQAccountOperation)
  public
    constructor Create; override;
  end;

  TRESModifyAccount = class(TResponsePackage);
  
  TREQModifyPassword = class(TRequestPackage)
  private
    fNewPassword: string;
    fOldPassword: string;
  public
    constructor Create; override;
  published
    property OldPassword: string read fOldPassword write fOldPassword;
    property NewPassword: string read fNewPassword write fNewPassword;
  end;

  TRESModifyPassword = class(TResponsePackage);

  TREQLockUser = class(TRequestPackage)
  private
    fReason: WideString;
    fComputerID: AnsiString;
  public
    constructor Create; override;
  published
    property ComputerID: AnsiString read fComputerID write fComputerID;
    property Reason: WideString read fReason write fReason;
  end;

  TRESLockUser = class(TResponsePackage);

  TREQDataset = class(TRequestPackage)
  private
    fPageIndex: Integer;
    fPageSize: Integer;
    fFilter: TDataSetFilter;
    procedure SetFilter(const Value: TDataSetFilter);
  public
    destructor Destroy; override;
  published
    property PageIndex: Integer read fPageIndex write fPageIndex;
    property PageSize: Integer read fPageSize write fPageSize;
    property Filter: TDataSetFilter read fFilter write SetFilter;
  end;

  TRESDataset = class(TResponsePackage)
  private
    fContent: TDzPersistentList;
    fPageCount: Integer;
    fRecordCount: Integer;
    fPageIndex: Integer;
    procedure SetContent(const Value: TDzPersistentList);
  public
    constructor Create; override;
    destructor Destroy; override;
    class function GetModelClass: TDzPersistentClass; virtual;
    procedure ExtractContent;
  published
    property PageCount: Integer read fPageCount write fPageCount;
    property RecordCount: Integer read fRecordCount write fRecordCount;
    property PageIndex: Integer read fPageIndex write fPageIndex;
    property Content: TDzPersistentList read fContent write SetContent;
  end;
  
  TREQGetPriVehicle = class(TREQDataset)
  public
    constructor Create; override;
  end;

  TRESGetPriVehicle = class(TRESDataset);

  TREQPriVehicleOperation = class(TRequestPackage)
  private
    fVehicle: TVehicle;
    procedure SetVehicle(const Value: TVehicle);
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Vehicle: TVehicle read fVehicle write SetVehicle;
  end;

  TREQAddPriVehicle = class(TREQPriVehicleOperation)
  public
    constructor Create; override;
  end;

  TRESAddPriVehicle = class(TRESAddObject);

  TREQModifyPriVehicle = class(TREQPriVehicleOperation)
  public
    constructor Create; override;
  end;

  TRESModifyPriVehicle = class(TResponsePackage)
  private
    fStateCode: Integer;
  published
    property StateCode: Integer read fStateCode write fStateCode;   
  end;

  TREQSendSMS = class(TRequestPackage)
  private
    fRecipients: TStrings;
    fText: WideString;
    procedure SetRecipients(const Value: TStrings);
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Recipients: TStrings read fRecipients write SetRecipients;
    property Text: WideString read fText write fText;
  end;

  TREQRemovePriVehicle = class(TREQRemoveObjs)
  public
    constructor Create; override;
  end;

  TRESRemovePriVehicle = class(TResponsePackage)
  private
    fRemovedCount: Integer;
  public
    procedure IncCount(Num: Integer = 1);
  published
    property RemovedCount: Integer read fRemovedCount write fRemovedCount;
  end;

  TREQGetShareVehicle = class(TREQDataset)
  public
    constructor Create; override;
  end;

  TREQGetWebShareVehicle = class(TREQDataset)
  public
    constructor Create; override;
  end;

  TRESGetShareVehicle = class(TRESDataset);

  TRESGetWebShareVehicle = class(TRESDataset);
  
  TREQGetLocPerson = class(TREQDataset)
  public
    constructor Create; override;
  end;

  TRESGetLocPerson = class(TRESDataset)
  public
    class function GetModelClass: TDzPersistentClass; override;
  end;

  TREQLocPersonOperation = class(TRequestPackage)
  private
    fPerson: TLocPerson;
    procedure SetPerson(const Value: TLocPerson);
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Person: TLocPerson read fPerson write SetPerson;
  end;

  TREQAddLocPerson = class(TREQLocPersonOperation)
  public
    constructor Create; override;
  end;

  TREQModifyLocPerson = class(TREQLocPersonOperation)
  public
    constructor Create; override;
  end;

  TRESAddLocPerson = class(TRESAddObject);

  TRESModifyLocPerson = class(TResponsePackage);
  
  TREQRemoveLocPerson = class(TREQRemoveObjs)
  public
    constructor Create; override;
  end;

  TRESRemoveLocPerson = class(TRESRemoveObjs);

  TRESSendSMS = class(TResponsePackage)
  private
    fSentCount: Integer;
    fCost: Integer;
  published
    property SentCount: Integer read fSentCount write fSentCount;
    property Cost: Integer read fCost write fCost;
  end;

  TREQLocSvc = class(TRequestPackage)
  private
    fObjType: TLBSObjectType;
    fObjectID: Integer;
    fPhone: string;
    fStateCode: Integer;
    fName: WideString;
  public
    property ObjType: TLBSObjectType read fObjType write fObjType;
    property Name: WideString read fName write fName;
  published
    property ObjectID: Integer read fObjectID write fObjectID;
    property Phone: string read fPhone write fPhone;
    property StateCode: Integer read fStateCode write fStateCode;
  end;

  TREQLocSvcClass = class of TREQLocSvc;

  TRESLocSvc = class(TResponsePackage)
  private
    fStateCode: Integer;
    fLbmpErrCode: Integer;
  published
    property StateCode: Integer read fStateCode write fStateCode;
    property LbmpErrCode: Integer read fLbmpErrCode write fLbmpErrCode;
  end;

  TREQQueryLocSvc = class(TREQLocSvc)
  public
    constructor Create; override;
  end;

  TRESQueryLocSvc = class(TRESLocSvc);

  TREQRegLocSvc = class(TREQLocSvc)
  public
    constructor Create; override;
  end;

  TRESRegLocSvc = class(TRESLocSvc);

  TREQCancelLocSvc = class(TREQLocSvc)
  public
    constructor Create; override;
  end;

  TRESCancelLocSvc = class(TRESLocSvc);
  
  TREQLocate = class(TRequestPackage)
  private
    fObjType: TLBSObjectType;
    fObjID: Integer;
    fPhone: string;
    fStateCode: Integer;
    fName: string;
  published
    property ObjType: TLBSObjectType read fObjType write fObjType;
    property ObjID: Integer read fObjID write fObjID;
    property Name: string read fName write fName;
    property Phone: string read fPhone write fPhone;
    property StateCode: Integer read fStateCode write fStateCode;
  end;

  TRESLocate = class(TRESLocSvc)
  private
    fCost: Integer;
  public
    Address: WideString;
  published
    property Cost: Integer read fCost write fCost;
  end;

  TREQCityLoc = class(TREQLocate)
  public
    constructor Create; override;
  end;

  TRESCityLoc = class(TRESLocate)
  private
    fCityID: Integer;
  published
    property CityID: Integer read fCityID write fCityID;
  end;

  TREQCoordLoc = class(TREQLocate)
  public
    constructor Create; override;
  public
    Driver: string;
  end;

  TRESCoordLoc = class(TRESLocate)
  private
    fLongitude: string;
    fLatitude: string;
  published
    property Longitude: string read fLongitude write fLongitude;
    property Latitude: string read fLatitude write fLatitude;
  end;

  TREQUpdateLocation = class(TRequestPackage)
  private
    fLocType: TLbmpLocType;
    fLongitude: string;
    fLatitude: string;
    fCityID: Integer;
    fPhone: string;
    fProvince: WideString;
    fID: Integer;
    fAddress: WideString;
    fCity: WideString;
  public
    function ProvCity: WideString;
    constructor Create; override;
  published
    property LocType: TLbmpLocType read fLocType write fLocType;
    property ID: Integer read fID write fID;
    property Phone: string read fPhone write fPhone;
    property Longitude: string read fLongitude write fLongitude;
    property Latitude: string read fLatitude write fLatitude;
    property CityID: Integer read fCityID write fCityID;
    property Province: WideString read fProvince write fProvince;
    property City: WideString read fCity write fCity;
    property Address: WideString read fAddress write fAddress;
  end;

  TREQAutoLoc = class(TRequestPackage)
  private
    fHour: Integer;
  public
    constructor Create; override;
  published
    property Hour: Integer read fHour write fHour;
  end;

  TRESAutoLoc = class(TResponsePackage);

  TREQGetLocTrace = class(TRequestPackage)
  private
    fObjID: Integer;
  public
    constructor Create; override;
  published
    property ObjID: Integer read fObjID write fObjID;
  end;

  TRESGetLocTrace = class(TResponsePackage)
  private
    fLocTrace: TLocTrace;
    procedure SetLocTrace(const Value: TLocTrace);
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property LocTrace: TLocTrace read fLocTrace write SetLocTrace;
  end;

  TREQAddLocTrace = class(TRequestPackage)
  private
    fLocTrace: TLocTrace;
    procedure SetLocTrace(const Value: TLocTrace);
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property LocTrace: TLocTrace read fLocTrace write SetLocTrace;
  end;

  TRESAddLocTrace = class(TResponsePackage)
  private
    fTraceID: Integer;
  published
    property TraceID: Integer read fTraceID write fTraceID;
  end;
    
  TREQModifyLocTrace = class(TRequestPackage)
  private
    fLocTrace: TLocTrace;
    procedure SetLocTrace(const Value: TLocTrace);
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property LocTrace: TLocTrace read fLocTrace write SetLocTrace;
  end;

  TRESModifyLocTrace = class(TResponsePackage);
  
  TREQRemoveLocTrace = class(TRequestPackage)
  private
    fTraceID: Integer;
  public
    constructor Create; override;
  published
    property TraceID: Integer read fTraceID write fTraceID;
  end;

  TRESRemoveLocTrace = class(TResponsePackage);

  TREQServerInfo = class(TRequestPackage)
  public
    constructor Create; override;
  end;
  
  TRESServerInfo = class(TResponsePackage)
  private
    fLaunchTime: TDateTime;
    fSessionCount: Integer;
    fVersion: string;
  protected
    procedure ReadProperties(const Reader: IDzClassReader;
      Options: TDzArchiveOptions); override;
    procedure WriteProperties(const Writer: IDzClassWriter;
      Options: TDzArchiveOptions); override;
  public
    RequestSummary: array [TRequestType] of LongInt;
  published
    property Version: string read fVersion write fVersion;
    property LaunchTime: TDateTime read fLaunchTime write fLaunchTime;
    property SessionCount: Integer read fSessionCount write fSessionCount;
  end;

const
  RequestClasses: array [TRequestType] of TRequestClass =
  (
    TREQAddAccount, //rtAddAccount
    TREQLogin, //rtLogin
    TREQLogout, //rtLogout
    TREQLockUser, //rtLockUser
    TREQModifyAccount, //rtModifyAccount
    TREQModifyPassword, //rtModifyPassword
    TREQGetPriVehicle, //rtGetPriVehicle
    TREQAddPriVehicle, //rtAddOrModifyVehicle
    TREQModifyPriVehicle, //rtModifyPriVehicle
    TREQRemovePriVehicle, //rtRemoveVehicle
    TREQGetShareVehicle, //rtGetShareVehicle
    TREQGetWebShareVehicle, //rtGetWebShareVehicle
    TREQGetLocPerson, //rtGetLocPerson
    TREQAddLocPerson, //rtAddLocPerson
    TREQModifyLocPerson, //rtModifyLocPerson
    TREQRemoveLocPerson, //rtRemoveLocPerson
    TREQSendSMS, //rtSendSms,
    TREQQueryLocSvc, //rtQueryLocSvc
    TREQRegLocSvc, //rtRegLocSvc
    TREQCancelLocSvc, //rtCancelLocSvc
    TREQCityLoc, //rtCityLoc
    TREQCoordLoc, //rtCoordLoc
    TREQUpdateLocation, //rtUpdateLocation
    TREQAutoLoc, //rtAutoLoc
    TREQGetLocTrace, //rtGetLocTrace
    TREQAddLocTrace, //rtAddLocTrace
    TREQModifyLocTrace, //rtModifyLocTrace
    TREQRemoveLocTrace, //rtRemoveLocTrace
    TREQServerInfo //rtServerInfo
  );

  ResponseClasses: array [TRequestType] of TResponseClass = (
    TRESAddAccount,
    TRESLogin,
    nil, //rtLogout
    TRESLockUser, //rtLockUser
    TRESModifyAccount, //rtModifyAccount
    TRESModifyPassword, //rtModifyPassword
    TRESGetPriVehicle, //rtGetPriVehicle
    TRESAddPriVehicle, //rtAddPriVehicle
    TRESModifyPriVehicle, //rtModifyPriVehicle
    TRESRemovePriVehicle, //rtRemoveVehicle
    TRESGetShareVehicle, //rtGetShareVehicle
    TRESGetWebShareVehicle, //rtGetWebShareVehicle
    TRESGetLocPerson, //rtGetLocPerson
    TRESAddLocPerson, //rtAddLocPerson
    TRESModifyLocPerson, //rtModifyLocPerson
    TRESRemoveLocPerson, //rtRemoveLocPerson
    TRESSendSMS, //rtSendSms,
    TRESQueryLocSvc, //rtQueryLocSvc
    TRESRegLocSvc, //rtRegLocSvc
    TRESCancelLocSvc, //rtCancelLocSvc
    TRESCityLoc, //rtCityLoc
    TRESCoordLoc, //rtCoordLoc
    nil,   //rtUpdateLocation
    TRESAutoLoc, //rtAutoLoc
    TRESGetLocTrace, //rtGetLocTrace
    TRESAddLocTrace, //rtAddLocTrace
    TRESModifyLocTrace, //rtModifyLocTrace
    TRESRemoveLocTrace,  //rtRemoveLocTrace
    TRESServerInfo //rtServerInfo
  );

procedure EncodePackage(PkgData: Pointer; PkgSize: Integer;
  Key: Pointer; KeyLen: Integer);

implementation

procedure EncodePackage(PkgData: Pointer; PkgSize: Integer;
  Key: Pointer; KeyLen: Integer);
var
  DPtr, KPtr: PAnsiChar;
  i: Integer;
begin
  DPtr := PAnsiChar(PkgData);
  KPtr := PAnsiChar(Key);
  for i := 0 to PkgSize - 1 do
  begin
    DPtr[i] := AnsiChar(Byte(DPtr[i]) xor PByte(KPtr)^);
    Inc(KPtr);
    if KPtr >= PAnsiChar(Key) + KeyLen then
      KPtr := PAnsiChar(Key); 
  end;
end;

{ TLoginResponse }

constructor TRESLogin.Create;
begin
  inherited;
  fUserInfo := TUserInfo.Create;
  fServerSetting := TServerSetting.Create;
end;

destructor TRESLogin.Destroy;
begin
  fUserInfo.Free;
  fServerSetting.Free;
  inherited;
end;

procedure TRESLogin.ReadProperties(const Reader: IDzClassReader;
  Options: TDzArchiveOptions);
begin
  inherited;
  if Reader.ReadDWord('StatusCode', fStatusCode) and (fStatusCode = CXT_E_SUCCESS) then
    ReadObject(Reader, 'UserInfo', fUserInfo);
end;

procedure TRESLogin.SetUserInfo(const Value: TUserInfo);
begin
  fUserInfo.Assign(Value);
end;

procedure TRESLogin.WriteProperties(const Writer: IDzClassWriter;
  Options: TDzArchiveOptions);
begin
  inherited;
  if Success then WriteObject(Writer, 'UserInfo', fUserInfo, Options);
end;

{ TREQLocPersonOperation }

constructor TREQLocPersonOperation.Create;
begin
  inherited;
  fPerson := TLocPerson.Create;
end;

destructor TREQLocPersonOperation.Destroy;
begin
  fPerson.Free;
  inherited;
end;

procedure TREQLocPersonOperation.SetPerson(const Value: TLocPerson);
begin
  fPerson.Assign(Value);
end;

{ TREQGetPriVehicle }

constructor TREQGetPriVehicle.Create;
begin
  fReqType := rtGetPriVehicle;
  fFilter := TPriVehicleFilter.Create;
  inherited;
end;

{ TRESRemovePriVehicle }

procedure TRESRemovePriVehicle.IncCount(Num: Integer);
begin
  Inc(fRemovedCount, Num);
end;

{ TREQSendSMS }

constructor TREQSendSMS.Create;
begin
  fReqType := rtSendSms;
  inherited;
  fRecipients := TStringList.Create;
end;

destructor TREQSendSMS.Destroy;
begin
  fRecipients.Free;
  inherited;
end;

procedure TREQSendSMS.SetRecipients(const Value: TStrings);
begin
  fRecipients.Clear;
  fRecipients.AddStrings(Value);
end;

{ TREQGetLocTrace }

constructor TREQGetLocTrace.Create;
begin
  fReqType := rtGetLocTrace;
  inherited;
end;

{ TREQModifyLocTrace }

constructor TREQAddLocTrace.Create;
begin 
  fReqType := rtAddLocTrace;
  inherited;
  fLocTrace := TLocTrace.Create;
end;

destructor TREQAddLocTrace.Destroy;
begin 
  fLocTrace.Free;
  inherited;
end;

procedure TREQAddLocTrace.SetLocTrace(const Value: TLocTrace);
begin 
  fLocTrace.Assign(Value)
end;

{ TREQModifyLocTrace }

constructor TREQModifyLocTrace.Create;
begin 
  fReqType := rtModifyLocTrace;
  inherited;
  fLocTrace := TLocTrace.Create;
end;

destructor TREQModifyLocTrace.Destroy;
begin 
  fLocTrace.Free;
  inherited;
end;

procedure TREQModifyLocTrace.SetLocTrace(const Value: TLocTrace);
begin 
  fLocTrace.Assign(Value)
end;

{ TREQRemoveLocTrace }

constructor TREQRemoveLocTrace.Create;
begin 
  fReqType := rtRemoveLocTrace;
  inherited;
end;

{ TRESGetLocTrace }

constructor TRESGetLocTrace.Create;
begin
  inherited;
  fLocTrace := TLocTrace.Create;
end;

destructor TRESGetLocTrace.Destroy;
begin
  fLocTrace.Free;
  inherited;
end;

procedure TRESGetLocTrace.SetLocTrace(const Value: TLocTrace);
begin
  fLocTrace.Assign(Value);
end;

{ TREQPriVehicleOperation }

constructor TREQPriVehicleOperation.Create;
begin
  inherited;
  fVehicle := TVehicle.Create;
end;

destructor TREQPriVehicleOperation.Destroy;
begin
  fVehicle.Free;
  inherited;
end;

procedure TREQPriVehicleOperation.SetVehicle(const Value: TVehicle);
begin
  fVehicle.Assign(Value);
end;

{ TREQGetShareVehicle }

constructor TREQGetShareVehicle.Create;
begin
  fReqType := rtGetShareVehicle;
  fFilter := TShareVehicleFilter.Create;
  inherited;
end;

{ TREQGetLocPerson }

constructor TREQGetLocPerson.Create;
begin
  fReqType := rtGetLocPerson;
  fFilter := TLocPersonFilter.Create;
  inherited;
end;

{ TRESGetLocPerson }

class function TRESGetLocPerson.GetModelClass: TDzPersistentClass;
begin
  Result := TLocPerson;
end;

{ TREQDataset }

destructor TREQDataset.Destroy;
begin
  fFilter.Free;
  inherited;
end;

procedure TREQDataset.SetFilter(const Value: TDataSetFilter);
begin
  fFilter.Assign(Value);
end;

{ TRESDataset }

constructor TRESDataset.Create;
begin
  inherited;
  fContent := TDzPersistentList.Create(GetModelClass);
end;

destructor TRESDataset.Destroy;
begin
  if fContent <> nil then fContent.Free;
  inherited;
end;

procedure TRESDataset.ExtractContent;
begin
  fContent := nil;
end;

class function TRESDataset.GetModelClass: TDzPersistentClass;
begin
  Result := TVehicle;
end;

procedure TRESDataset.SetContent(const Value: TDzPersistentList);
begin
  fContent.Assign(Value);
end;

{ TREQAccountOperation }

constructor TREQAccountOperation.Create;
begin
  inherited;
  fUserInfo := TUserInfo.Create;
end;

destructor TREQAccountOperation.Destroy;
begin
  fUserInfo.Free;
  inherited;
end;

procedure TREQAccountOperation.SetUserInfo(const Value: TUserInfo);
begin
  FUserInfo.Assign(Value);
end;

{ TRESServerInfo }

procedure TRESServerInfo.ReadProperties(const Reader: IDzClassReader;
  Options: TDzArchiveOptions);
var
  rtype: TRequestType;
begin
  inherited;
  for rtype := Low(RequestSummary) to High(RequestSummary) do
    Reader.ReadDWord(ReqTypeNames[rtype], RequestSummary[rtype]);
end;

procedure TRESServerInfo.WriteProperties(const Writer: IDzClassWriter;
  Options: TDzArchiveOptions);
var
  rtype: TRequestType;
begin
  inherited;
  for rtype := Low(RequestSummary) to High(RequestSummary) do
    Writer.WriteDWord(ReqTypeNames[rtype], RequestSummary[rtype]);
end;

{ TResponsePackage }

constructor TResponsePackage.Create;
begin
  inherited;
  fStatusCode := CXT_E_SUCCESS;
  fStatusText := '';
  fServerTime := Now;
end;

function TResponsePackage.GetSuccess: Boolean;
begin
  Result := StatusCode = CXT_E_SUCCESS;
end;

{ TREQUpdateLocation }

constructor TREQUpdateLocation.Create;
begin
  fReqType := rtUpdateLocation;
  inherited;
end;

function TREQUpdateLocation.ProvCity: WideString;
begin
  if fProvince = fCity then Result := fCity
  else Result := fProvince + fCity;
end;

{ TREQRemoveObjs }

constructor TREQRemoveObjs.Create;
begin
  inherited;
  fObjs := TDzPersistentList.Create(TObjectKey);
end;

destructor TREQRemoveObjs.Destroy;
begin
  fObjs.Free;
  inherited;
end;

procedure TREQRemoveObjs.SetObjs(const Value: TDzPersistentList);
begin
  fObjs.Assign(Value);
end;

{ TREQLogin }

constructor TREQLogin.Create;
begin
  inherited;
  fReqType := rtLogin;
end;

{ TREQAddAccount }

constructor TREQAddAccount.Create;
begin
  fReqType := rtAddAccount;
  inherited;
end;

{ TREQModifyPassword }

constructor TREQModifyPassword.Create;
begin
  fReqType := rtModifyPassword;
  inherited;
end;

{ TREQLockUser }

constructor TREQLockUser.Create;
begin
  fReqType := rtLockUser;
  inherited;
end;

{ TREQAddPriVehicle }

constructor TREQAddPriVehicle.Create;
begin
  fReqType := rtAddPriVehicle;
  inherited;
end;

{ TREQModifyPriVehicle }

constructor TREQModifyPriVehicle.Create;
begin
  inherited;
  fReqType := rtModifyPriVehicle;
end;

{ TREQRemovePriVehicle }

constructor TREQRemovePriVehicle.Create;
begin
  fReqType := rtRemovePriVehicle;
  inherited;
end;

{ TREQAddLocPerson }

constructor TREQAddLocPerson.Create;
begin
  fReqType := rtAddLocPerson;
  inherited;
end;

{ TREQModifyLocPerson }

constructor TREQModifyLocPerson.Create;
begin
  fReqType := rtModifyLocPerson;
  inherited;
end;

{ TREQRemoveLocPerson }

constructor TREQRemoveLocPerson.Create;
begin
  fReqType := rtRemoveLocPerson;
  inherited;
end;

{ TREQQueryLocSvc }

constructor TREQQueryLocSvc.Create;
begin
  fReqType := rtQueryLocSvc;
  inherited;
end;

{ TREQRegLocSvc }

constructor TREQRegLocSvc.Create;
begin
  fReqType := rtRegLocSvc;
  inherited;
end;

{ TREQCancelLocSvc }

constructor TREQCancelLocSvc.Create;
begin
  fReqType := rtCancelLocSvc;
  inherited;
end;

{ TREQCityLoc }

constructor TREQCityLoc.Create;
begin
  fReqType := rtCityLoc;
  inherited;
end;

{ TREQCoordLoc }

constructor TREQCoordLoc.Create;
begin
  fReqType := rtCoordLoc;
  inherited;
end;

{ TREQAutoLoc }

constructor TREQAutoLoc.Create;
begin
  fReqType := rtAutoLoc;
  inherited;
end;

{ TREQServerInfo }

constructor TREQServerInfo.Create;
begin
  fReqType := rtServerInfo;
  inherited;
end;

{ TREQLogout }

constructor TREQLogout.Create;
begin
  fReqType := rtLogout;
  inherited;
end;

{ TREQGetWebShareVehicle }

constructor TREQGetWebShareVehicle.Create;
begin
  fReqType := rtGetWebShareVehicle;
  fFilter := TShareVehicleFilter.Create;
  inherited;
end;

{ TREQModifyAccount }

constructor TREQModifyAccount.Create;
begin
  fReqType := rtModifyAccount;
  inherited;
end;

end.


